package cn.iocoder.yudao.hires.controller.admin.notice.app;


import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.hires.entity.NoticeOfferDO;
import cn.iocoder.yudao.hires.service.notice.NoticeOfferService;
import cn.iocoder.yudao.hires.vo.noticeoffer.NoticeOfferPageReqVO;
import cn.iocoder.yudao.hires.vo.noticeoffer.NoticeOfferRespVO;
import cn.iocoder.yudao.hires.vo.noticeoffer.NoticeOfferSaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 下游-Offer通知")
@RestController
@RequestMapping("/app/notice-offer")
@Validated
public class AppNoticeOfferController {

    @Resource
    private NoticeOfferService noticeOfferService;


    @PostMapping("/create")
    @Operation(summary = "创建下游-Offer通知")
    //@PreAuthorize("@ss.hasPermission('system:notice-offer:create')")
    public CommonResult<Long> createNoticeOffer(@Valid @RequestBody NoticeOfferSaveReqVO createReqVO) {
        return success(noticeOfferService.createNoticeOffer(createReqVO));
    }


    @GetMapping("/list")
    @Operation(summary = "获得下游-Offer通知")
    @TenantIgnore
    //@PreAuthorize("@ss.hasPermission('system:notice-offer:query')")
    public CommonResult<List<NoticeOfferDO>> getNoticeOfferList(Long userId,String tenantName,Long tenantId, Integer status) {
        return success(noticeOfferService.getNoticeOfferList(userId,tenantName,tenantId,status));
    }



    @GetMapping("/get")
    @Operation(summary = "获得下游-Offer通知")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    //@PreAuthorize("@ss.hasPermission('system:notice-offer:query')")
    public CommonResult<NoticeOfferRespVO> getNoticeOffer(@RequestParam("id") Long id) {
        NoticeOfferDO noticeOffer = noticeOfferService.getNoticeOffer(id);
        return success(BeanUtils.toBean(noticeOffer, NoticeOfferRespVO.class));
    }


    @PostMapping("/update")
    @Operation(summary = "更新下游-Offer通知")
    @TenantIgnore
    public CommonResult<Boolean> updateNoticeOffer(@Valid @RequestBody NoticeOfferSaveReqVO updateReqVO) {
        noticeOfferService.updateNoticeOffer(updateReqVO);
        return success(true);
    }
}